"""
Test with direct client creation
"""

import pytest
import asyncio
import sys
import os
sys.path.insert(0, os.getcwd())

from httpx import AsyncClient, ASGITransport
from main import app


@pytest.mark.asyncio
async def test_root_endpoint():
    """Test root endpoint with direct client creation"""
    transport = ASGITransport(app=app)
    async with AsyncClient(transport=transport, base_url="http://test") as client:
        response = await client.get("/")
        assert response.status_code == 200
        data = response.json()
        assert "message" in data
        print("✅ Root endpoint test passed")


@pytest.mark.asyncio
async def test_health_endpoint():
    """Test health endpoint with direct client creation"""
    transport = ASGITransport(app=app)
    async with AsyncClient(transport=transport, base_url="http://test") as client:
        response = await client.get("/health")
        assert response.status_code == 200
        data = response.json()
        assert data["status"] == "healthy"
        print("✅ Health endpoint test passed")


if __name__ == "__main__":
    asyncio.run(test_root_endpoint())
    asyncio.run(test_health_endpoint())
    print("✅ All direct client tests passed!")